/*
 * Copyright @2009-2012 www.happyelements.com, all rights reserved.
 * Create date: 2012-7-30
 * Chengzhi.yin	
 * 尹成志
 * chengzhi.yin@happyelements.com
 */
package com.happyelements.components
{
	import com.bit101.components.Slider;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	public class VerticalSlider extends Slider
	{
		private static const SCALE:Number = 1 ;
		private var _color:uint = 0x000000;
		
		public function VerticalSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null)
		{
			super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler);
		}
		
		override protected function drawHandle():void
		{	
			_handle.graphics.clear();
			_handle.graphics.beginFill(_color);
			_handle.graphics.drawRect(1, 1, _width - 2, _width * SCALE - 2);
			_handle.graphics.endFill();
			positionHandle();
		}
		
		override protected function onDrag(event:MouseEvent):void
		{
			stage.addEventListener(MouseEvent.MOUSE_UP, onDrop);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onSlide);
			_handle.startDrag(false, new Rectangle(0, 0, 0, _height - _width * SCALE));
		}
		
		public function set color(value:uint):void
		{
			this._color = value;
		}
	}
}